const { defineConfig } = require('@vue/cli-service')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const path = require('path')
module.exports = defineConfig({
  transpileDependencies: true,
  pages:{
    index: {//用于配置默认索引
      entry: 'src/main.js',
      template: 'public/index.html',
      filename: 'index.html',
    },
  },
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
      },
    },
    devServer: {
      port: 18089,
      open: true,
      proxy: {
        '/api/v1': {
          target: 'http://localhost:3000', //后端服务器地址
          changeOrigin: true, //允许跨域
          
        }
      },
      // 使用新的配置格式
      devMiddleware: {
        publicPath: '/'
      },
      // 静态资源配置
      static: {
        directory: path.join(__dirname, 'public'),
        publicPath: '/'
      },
    },
    plugins: [
      new CopyWebpackPlugin({
        patterns: [
          { from: 'static', to: 'static' },
        ],
      }),
    ],
  },
  lintOnSave: false,
})
